package com.mall.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mall.dubbo.mapper.PmsSkuStockMapper;
import com.mall.model.domain.PmsSkuStock;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @author xyiaao
 * @description 针对表【pms_sku_stock(sku的库存)】的数据库操作Api实现
 * @createDate 2022-03-29 19:46:09
 */
@DubboService
public class PmsSkuStockApiImpl extends ServiceImpl<PmsSkuStockMapper, PmsSkuStock>
        implements PmsSkuStockApi {

    @Autowired
    private PmsSkuStockMapper skuStockMapper;

    @Override
    public List<PmsSkuStock> findByProductId(Integer id) {

        LambdaQueryWrapper<PmsSkuStock> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(PmsSkuStock::getProductId, id);

        List<PmsSkuStock> pmsSkuStocks = skuStockMapper.selectList(queryWrapper);
        return pmsSkuStocks;
    }

    @Override
    public List<PmsSkuStock> findByPidAndCode(Integer pid, String keyword) {

        LambdaQueryWrapper<PmsSkuStock> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(PmsSkuStock::getProductId, pid)
                .eq(keyword != null, PmsSkuStock::getSkuCode, keyword);
        List<PmsSkuStock> skuStockList = skuStockMapper.selectList(queryWrapper);
        return skuStockList;
    }


}




